<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>UIC iClock</title>

    <script>
        window.onload = getTime; //网页加载完就调用getTime()方法
        function getTime() {
            var today = new Date(); //获取当前系统时间
            var hours = today.getHours(); //获取小时
            var minutes = today.getMinutes(); //获取分
            var seconds = today.getSeconds(); //获取秒
            updateTime();

            function updateTime() {
                if (seconds == -1) { //当second减到-1时重置second并minutes减一
                    minutes = minutes - 1;
                    seconds = 59;
                }
                if (minutes == -1) { //当minutes减到-1时重置mintes并hours减一
                    hours = hours - 1;
                    minutes = 59;
                }
                if (hours == -1) { //当hours减到-1时重置hours
                    hours = 23;
                }
                if (seconds < 10) { //在前面添加0
                    var secondsDisplay = "0" + seconds;
                } else {
                    var secondsDisplay = seconds;
                }
                if (minutes < 10) { //在前面添加0
                    var minutesDisplay = "0" + minutes;
                } else {
                    var minutesDisplay = minutes;
                }
                if (hours < 10) { //在前面添加0
                    var hoursDisplay = "0" + hours;
                } else {
                    var hoursDisplay = hours;
                }
                //把时分秒拼起来得到时间
                var time = hoursDisplay + ":" + minutesDisplay + ":" + secondsDisplay;
                //把时间显示在div上,您自己可以放在网页任何位置,反正时间就是time
                document.getElementById("div").innerHTML = time;
                //每隔一秒更新一次时间
                seconds = seconds - 1; //每秒second减一
                setTimeout(updateTime, 1000);
            }
        }
    </script>
</head>

<body>
    <div style="text-align: center; margin-top: 80px">
        <img src="img/UIC-logo.jpg" alt="" />
    </div>
    <div id="div" style="
        margin-top: 20px;
        font-size: 300px;
        font-weight: bold;
        text-align: center;
      "></div>
</body>

</html>